package com.ajx.cube.module.login;

import android.support.annotation.NonNull;
import android.view.View;
import android.widget.EditText;
import android.widget.ProgressBar;

import com.ajx.cube.MainActivity;
import com.ajx.cube.R;
import com.ajx.cube.base.BaseActivity;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by lai on 2017/12/11.
 */

public class LoginActivity extends BaseActivity<ILoginView, LoginPresenter> implements ILoginView {

    @BindView(R.id.login_progress)
    ProgressBar loginProgress;
    @BindView(R.id.email)
    EditText email;
    @BindView(R.id.password)
    EditText password;

    @Override
    public void onLogin(String account) {
        showMessage(account.replaceAll("\"",""));
        startActivity(MainActivity.class,true);
        finish();
    }

    @NonNull
    @Override
    public LoginPresenter createPresenter() {
        return new LoginPresenter(this, this);
    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_login;
    }

    @Override
    protected void init() {

    }



    @Override
    public void showLoading() {
        loginProgress.setVisibility(View.VISIBLE);
    }

    @Override
    public void closeLoading() {
        loginProgress.setVisibility(View.GONE);
    }

    @Override
    public void showMessage(String msg) {
        toast(msg);
    }

    @OnClick(R.id.btn_login)
    public void onViewClicked() {
        getPresenter().login(email,password);
    }


}
